home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Perl Multimedia Cyber Classroom
/
PERL Multimedia Cyber Classroom (Prentice Hall)(1998).ISO
/
perlbyex
/
code.jar
/
13ex007.jar
/
code
/
ch13
/
13ex007
/
13ex007.pl
next >
Wrap
Perl Script
|
1998-04-01
|
582b
|
23 lines
#!/bin/perl
package Employee;
sub new{
my $class = shift;
$worker={Name=>undef,
Salary=>undef,
};
bless($worker, $class);
return $worker;}
sub DESTROY{
my $self = shift;
print "$self->{Name}\n" ;
delete $self->{Name}; # remove the (object);
print "Hash Name entry has been destroyed. Bailing out.\n" if ( ! exists
$self->{Name});
}
package main;
$empref = new Employee; # create the object
$empref->{Name}= "Dan Savage" ;
$empref->{Salary}=10000;
print "Name is $empref->{Name}.\n" ;
print "Salary is $empref->{Salary}.\n" ;